import { orderColumns } from './allOrder.config.js'
import search from './../search/search.js';
import formNode from '@/views/com/formNode.vue'
export default {
    name: "allOrder",
    mixins: [search],
    components: {
        formNode,
    },
    data() {
        return {
            orderColumns,
            loading: false,
            loadData: [{
                id: 1,
                sl: 22,
                hy: 33
            }],
            pagination: {
                total: 0,
                current: 1,
                pageSize: 10,
                showSizeChanger: true,
                showTotal: total => `共有${total}条`
            },
            formNodeList: [
                {
                    type: 'input',
                    label: "姓名",
                    prop: "name",
                    placeholder: "false",
                    slot: "prefix",
                    icon: 'user',
                    change: (e) => {
                        console.log(e)
                    },
                    blur: (e, val) => {
                        console.log(val)
                    },
                },
                {
                    type: 'select',
                    label: "联系电话",
                    prop: "phone",
                    option: [
                        {
                            label: "手机",
                            value: 15314216721
                        },
                        {
                            label: "座机",
                            value: 6501831
                        }
                    ],
                    change: (e) => {
                        console.log(e)
                    }
                },
                {
                    type: 'checkbox',
                    label: "多选",
                    prop: "duoxaun",
                    checkboxValue: [
                        {
                            label: "韭菜盒子",
                            value: 1
                        },
                        {
                            label: "火腿肠",
                            value: 2
                        }
                    ],
                    change: (e) => {
                        console.log(e)
                    }
                },
                {
                    type: 'radio',
                    label: "单选",
                    prop: "danxuan",
                    radioValue: [
                        {
                            label: "A",
                            value: 1
                        },
                        {
                            label: "B",
                            value: 2
                        }
                    ],
                    change: (e, val) => {
                        console.log(val)
                    }
                },
                {
                    type: 'textarea',
                    label: "文本域",
                    prop: "wenbenyu",
                    change: (e) => {
                        console.log(e)
                    },
                    blur: (e, val) => {
                        console.log(val)
                    },
                },
                {
                    type: 'switch',
                    label: "开关",
                    prop: "kaiguan",
                    checkedChildren: "开",
                    unCheckedChildren: "关",
                    defaultChecked: true,
                    change: (e) => {
                        console.log(e)
                    },
                },
                {
                    type: 'rangePicker',
                    label: "时间段",
                    prop: "shijianduan",
                    placeholder: ["开始时间", "结束时间"],
                    format: "YYYY-MM-DD HH:mm",
                    change: (e) => {
                        var timeList = [this.formDate(e[0]._d), this.formDate(e[1]._d)]
                        console.log(timeList)
                    },
                    // slot:"suffixIcon"
                },
            ],
            rules: {
                name: [
                    { required: true, message: '请输入活动名称', trigger: 'blur' },
                    { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
                ],
            },
            form: {},
        }
    },
    methods: {
        getList(searchForm, page) {
            if (searchForm) {
                console.log(searchForm)
            }
            if (page) {
                this.pagination.current = page
            }
            setTimeout(() => {
                this.pagination.total = 11
                this.$emit("trigger")
            }, 500)
        },
        handleTableChange(pagination) {
            this.pagination.current = pagination.current
            this.pagination.pageSize = pagination.pageSize
            this.getList()
        },
        orderDetails(record) {
            console.log(record)
            this.$router.push({ path: "/mall/order/details", query: { id: record.id } })
        },
        handleOk() {
            this.$refs.form.$refs.form.validate((valid) => {
                if (valid) {
                    console.log(this.form)
                } else {
                    console.log('error submit!!');
                    return false;
                }
            })
        }
    }

} 